#!/bin/bash
# 获取shell脚本当前目录
# shellcheck disable=SC2034
PATH_BASE="$( cd "$( dirname "$0"  )" && pwd  )"
PATH_API=$PATH_BASE/donald-api
PATH_CONSUMER=$PATH_BASE/donald-consumer
PATH_PROVIDER=$PATH_BASE/donald-provider
PATH_XXL=$PATH_BASE/donald-xxl-job-executor
PATH_PROVIDER_GAME=$PATH_BASE/donald-provider-game
PATH_PROVIDER_LOG=$PATH_BASE/donald-provider-log

#cd $PATH_BASE
#echo "maven cleaning"
#sudo mvn clean

#echo "maven installing"
#sudo mvn install


echo "nohup java -Xms128m -Xmx256m -jar ${PATH_PROVIDER}/target/*.jar --spring.profiles.active=test >> ${PATH_PROVIDER}/nohup.out 2>&1 &"
nohup java -Xms128m -Xmx256m -jar ${PATH_PROVIDER}/target/*.jar --spring.profiles.active=test >> ${PATH_PROVIDER}/nohup.out 2>&1 & echo " ${!}" >> ${PATH_BASE}/pid.txt

echo "nohup java -Xms64m -Xmx128m -jar ${PATH_PROVIDER_GAME}/target/*.jar --spring.profiles.active=test >> ${PATH_PROVIDER_GAME}/nohup.out &"
nohup java -Xms64m -Xmx128m -jar ${PATH_PROVIDER_GAME}/target/*.jar --spring.profiles.active=test >> ${PATH_PROVIDER_GAME}/nohup.out & echo " ${!}" >> ${PATH_BASE}/pid.txt

echo "sudo nohup java -Xms128m -Xmx256m -jar ${PATH_PROVIDER_LOG}/target/*.jar --spring.profiles.active=test >> ${PATH_PROVIDER_LOG}/nohup.out &"
nohup java -Xms128m -Xmx256m -jar ${PATH_PROVIDER_LOG}/target/*.jar --spring.profiles.active=test >> ${PATH_PROVIDER_LOG}/nohup.out & echo " ${!}" >> ${PATH_BASE}/pid.txt

echo "sudo nohup java -Xms64m -Xmx128m -jar ${PATH_CONSUMER}/target/*.jar --spring.profiles.active=test >> ${PATH_CONSUMER}/nohup.out 2>&1 &"
nohup java -Xms64m -Xmx128m -jar ${PATH_CONSUMER}/target/*.jar --spring.profiles.active=test >> ${PATH_CONSUMER}/nohup.out 2>&1 & echo " ${!}" >> ${PATH_BASE}/pid.txt

echo "sudo nohup java -Xms32m -Xmx64m -jar ${PATH_XXL}/target/*.jar --spring.profiles.active=test >> ${PATH_XXL}/nohup.out &"
nohup java -Xms32m -Xmx64m -jar ${PATH_XXL}/target/*.jar --spring.profiles.active=test >> ${PATH_XXL}/nohup.out & echo " ${!}" >> ${PATH_BASE}/pid.txt
